Comment: HK velferd Kom Setup Menu Project
 
[DEFINE REGION: Check Application Requirements]
Get System Setting Windows XP into CHECKSYSTEM
if Variable CHECKSYSTEM not Equals TRUE
  MessageBox: $TITLE$ Setup Error, This product requires at least Windows XP.$NEWLINE$$NEWLINE$Setup cannot continue.
  Terminate Installation
end
[END REGION]
 
[DEFINE REGION: Check/Install Application Pre-Requisites]
 
[DEFINE REGION: Check Application Pre-Requisites]
Comment: Check setup pre-requisites
Set Variable PREREQ to FALSE
Set Variable PRELIST to 
[compiler if Variable BUILDMODE not Equals PATCH]
if Variable NEEDSUPGRADE Equals TRUE
  Set Variable PREREQ to TRUE
  Set Variable PRELIST to $PRELIST$$NEWLINE$Previous Version Uninstallation
end
[compiler end]
[END REGION]
 
[DEFINE REGION: Install Application Pre-Requisites]
Comment: Install setup pre-requisites
if Variable PREREQ not Equals FALSE
  Comment: Display Dialog: prereq, wait for dialog to return (modal)
  if Variable WIZARD Equals CANCEL
    Terminate Installation
  end
  Comment: Display Dialog: progressprereq, use as progress dialog (non-modal)
  [compiler if Variable BUILDMODE not Equals PATCH]
  if Variable NEEDSUPGRADE Equals TRUE
    Set Variable REMOVEOLD to 
    Set Variable ERROROLD to 
    Install/Remove MSI Package $PRODUCTCODE$[REMOVE=ALL] (get result into variable REMOVEOLD)
    if Variable REMOVEOLD Equals ERROR
      MessageBox: $TITLE$ Setup, Unable to uninstall old version of $TITLE$. Please uninstall it yourself using Control Panel Add-Remove Programs before attempting to install this product.$NEWLINE$$NEWLINE$$ERROROLD$
      Terminate Installation
    end
    if Variable REMOVEOLD Equals REBOOT
      MessageBox: $TITLE$ Setup, Your computer needs to be restarted before $TITLE$ Setup can continue.$NEWLINE$$NEWLINE$Please save your work in all running programs and click OK to restart your computer. Setup will resume once your computer restarts.$NEWLINE$$NEWLINE$If you click CANCEL, setup will exit. You will have to run setup again at a later time to install $TITLE$.
      if Variable REBOOTNOW Equals OK
        Reboot Computer and Resume Setup
      else
        Terminate Installation
      end
    end
    Set Variable MAINTENANCE to FALSE
  end
  [compiler end]
  Hide Dialog
end
[END REGION]
 
[END REGION]
 
[DEFINE REGION: Define Setup Globals]
Comment: Define Setup Components
Define Component: Default
 
Set Variable PROGRAM to HK velferd
Set Variable PROGRAMSHORT to HKvelferd
Set Variable HKDB to HKDB.TXT
Set Variable FILEININST to HKvelferd.exe
Set Variable OURCOMPANY to HK data
Set Variable LES1 to FALSE
Set Variable OPPGRADER to FALSE
Set Variable KONVERTER to FALSE
Set Variable HJEMMESIDE to FALSE
 
Comment: Detect and Set 64 bit Mode
Get System Setting Windows in 64 bit Mode into 64BITMODE
if Variable 64BITMODE Equals TRUE
  Get System Setting Processor Architecture into ARCHITECTURE
  if Variable ARCHITECTURE Equals Itanium
    Set Itanium ia64 - Native 64 bit Windows, Intel Itanium Architecture - installation mode
  else
    Set x64 - Native 64 bit Windows, AMD64 and EM64T Architectures - installation mode
  end
else
  Set Win32 - Native 32 bit Windows and Windows 32 on Windows 64 (WOW64) - installation mode
  Comment: EVT: MessageBox med: "Denne installasjonen er kun gyldig for 64-bits operativsystem" og Terminate Installation
end
 
Comment: Initialize Setup Globals
Get System Setting Windows NT Kernel (NT4, 2000, XP, 2003, Vista, 2008, 7, 2008 R2, 8, 2012) into ISNT
Get Folder Location System->Program Files Directory into PROGRAMFILES
Get Common Folder Location System->Program Files Directory into COMMONFILES
Get Common Folder Location Start Menu->Programs Group into SHORTCUTFILESALL
Get Folder Location Start Menu->Programs Group into SHORTCUTFILES
Set Variable ALLUSERS to TRUE
if Variable SHORTCUTFILESALL Equals 
  Set Variable SHORTCUTFILESALL to $SHORTCUTFILES$
end
Get Folder Location System->Desktop Directory into DESKTOPDIR
Get Folder Location System->Windows Directory into WINDIR
Get Folder Location System->System Directory into WINSYSDIR
Get Folder Location Taskbar->Quick Launch Directory into QUICKLAUNCHDIR
Get Folder Location WWW->WWWRoot into WWWROOTDIR
[END REGION]
 
[DEFINE REGION: Setup User Interview]
if Variable MAINTENANCE Equals TRUE
  GoTo Label: Maintenance
else
  [compiler if Variable BUILDMODE not Equals PATCH]
  Comment: First Time Install
  Set Variable TARGETDIR to 
  Set Variable STARTMENU to 
  [compiler end]
end
 
label: Welcome Dialog
Comment: Display Dialog: welcome, wait for dialog to return (modal)
if Variable WIZARD Equals CANCEL
  GoTo Label: Main Install
end
[compiler if Variable BUILDMODE not Equals PATCH]
label: License Check
Comment: Display Dialog: licensecheck, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Welcome Dialog
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: ReadMe Information
Comment: Display Dialog: readme, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: License Check
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: User Registration
Comment: Display Dialog: registration, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: ReadMe Information
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: Setup Type
Comment: Display Dialog: setuptype, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: User Registration
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
Comment: TO-DO: Customize your minimum setup here
if Variable MINIMUM Equals TRUE
  Deselect Component: Default
  Deselect Component: Default\Admin
  Deselect Component: Default\Admin\Firebird SuperServer
else
  if Variable COMPLETE Equals TRUE
    Select Component: Default
    Select Component: Default\Admin
    Select Component: Default\Admin\Firebird SuperServer
  end
end
label: Custom Setup
Comment: Display Dialog: componentstree (if variable PERSONALIZED is TRUE), wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Setup Type
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: Destination Directory
Comment: Display Dialog: destination, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Custom Setup
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
label: Start Menu
Comment: Display Dialog: startmenu, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  GoTo Label: Destination Directory
else
  if Variable WIZARD Equals CANCEL
    GoTo Label: Main Install
  end
end
[compiler end]
label: Start Installation
Comment: Display Dialog: startinstallation, wait for dialog to return (modal)
if Variable WIZARD Equals BACK
  [compiler if Variable BUILDMODE not Equals PATCH]
  GoTo Label: Start Menu
  [compiler else]
  GoTo Label: Welcome Dialog
  [compiler end]
else
  GoTo Label: Main Install
end
 
label: Maintenance
Comment: Maintenance Install/Uninstall
wizard loop
Comment: Display Dialog: maintenance, wait for dialog to return (modal)
Comment: Display Dialog: componentstree (if variable MODIFY is TRUE), wait for dialog to return (modal)
Comment: Display Dialog: startinstallation, wait for dialog to return (modal)
end
[END REGION]
 
[DEFINE REGION: test]
label: Main Install
Comment: Exit Setup if Wizard Loop cancelled
if Variable WIZARD Equals CANCEL
  Terminate Installation
end
 
Comment: Prepare to install
Set Variable PROGRESSTEXT to Installing $TITLE$
Set Variable SUCCESS to 
Set Variable LASTERROR to 
if Variable ALLUSERS Equals TRUE
  Set Variable SHORTCUTFOLDER to $SHORTCUTFILESALL$\$STARTMENU$
else
  Set Variable SHORTCUTFOLDER to $SHORTCUTFILES$\$STARTMENU$
end
Comment: Display Dialog: progress, use as progress dialog (non-modal)
 
Comment: Modify Target System
[DEFINE REGION: Perform Uninstallation]
if Variable REMOVE Equals TRUE
  MessageBox: $TITLE$ Debug, Variabel MODIFY: $MODIFY$$NEWLINE$Variabel REMOVE: $REMOVE$$NEWLINE$Variabel UNINSTALL: $UNINSTALL$
  Comment: Uninstall product
  Comment: TO-DO: Insert any additional uninstall commands here
  Does Folder Exist $PROGRAMFILES$\Firebird\Firebird_2_1 (get result into variable FOLDEREXIST)
  if Variable FOLDEREXIST Equals TRUE
    Run Program $PROGRAMFILES$\Firebird\Firebird_2_1\bin\instsvc.exe stop (WAIT, get result into variable INSTALLSUPER)
    Run Program $PROGRAMFILES$\Firebird\Firebird_2_1\bin\instsvc.exe remove -z (WAIT, get result into variable INSTALLSUPER)
    Run Program $PROGRAMFILES$\Firebird\Firebird_2_1\bin\instreg.exe remove -z (WAIT, get result into variable INSTALLSUPER)
  end
  Apply Uninstall (get result into variable SUCCESS)
  if Variable FOLDEREXIST Equals TRUE
    Recursively Delete Files $PROGRAMFILES$\Firebird\Firebird_2_1\*.*
  end
  Set Variable PROGRESS to 100
else
  [END REGION]
  [DEFINE REGION: Perform First Time or Maintenance Installation]
  Comment: Install/Re-Install product
  [OFFLINE CONTENT]
  Comment: if Variable BITMODE not Equals SUCCESS
  Comment: TO-DO: Insert any additional install commands here
  Set Variable RUNAPP to FALSE
  [compiler if Variable BUILDMODE Equals PATCH]
  Apply Patch (get result into variable SUCCESS)
  [compiler else]
  if Variable ADVERTISE Equals TRUE
    Apply Advertised (get result into variable SUCCESS)
  else
    Get Component Default Selection State into Variable SELECTED
    if Variable SELECTED Equals TRUE
      label: Setup Menu
      Display Dialog: setuptype, wait for dialog to return (modal)
      if Variable WIZARD Equals CANCEL
        GoTo Label: FINISHPROJECT
      end
      if Variable LES1 Equals TRUE
        GoTo Label: Display PDF 1
      end
      if Variable OPPGRADER Equals TRUE
        GoTo Label: Oppgrader
      end
      if Variable KONVERTER Equals TRUE
        GoTo Label: Konverter
      end
      if Variable HJEMMESIDE Equals TRUE
        GoTo Label: Hjemmeside
      end
    end
  end
   
  label: Display PDF 1
  Set Variable NATIVE_ENGINE to TRUE
  Parse String $SETUPPATH$ into Variables SETUPDIR and REST (Split at last occurrence of pattern)
  Get File Version $SETUPDIR$\Program\$FILEININST$ into Variable FILEININSTVERSION
  Run Program "$SETUPPATH$$PROGRAMSHORT$_$FILEININSTVERSION$_Installasjonsveiledning.pdf" 
  Set Variable NATIVE_ENGINE to FALSE
  GoTo Label: Setup Menu
   
  label: Konverter
  Parse String $SETUPPATH$ into Variables SETUPDIR and REST (Split at last occurrence of pattern)
  Check Service State for FirebirdServerDefaultInstance (write result into variable SERVICECHECK)
  if Variable SERVICECHECK not Equals RUNNING
    MessageBox: $PROGRAM$ - Advarsel, Denne konverteringen krever at Firebird Service kjører, noe den ikke ser ut til å gjøre nå.$NEWLINE$$NEWLINE$Start servicen "Firebird Server - DefaultInstance" eller installer full-versjonen av Firebird Server og klikk No/Nei for å kjøre konverteringen senere.$NEWLINE$$NEWLINE$Kjører servicen under et annet navn, klikk Yes/Ja for å fortsette konverteringen.
    if Variable SERVICERESPONSE Equals NO
      GoTo Label: Setup Menu
    end
  end
  Set Variable NATIVE_ENGINE to TRUE
  label: Finn Programkatalog 2
  Set Variable TARGETDIR to 
  Display Dialog: destination, wait for dialog to return (modal)
  if Variable WIZARD Equals CANCEL
    GoTo Label: Setup Menu
  end
  Does File Exist $TARGETDIR$\$FILEININST$ (get result into variable FILEEXIST)
  if Variable $FILEEXIST$ not Equals TRUE
    MessageBox: $PROGRAM$ - Advarsel, Dette er ikke program-katalogen!$NEWLINE$$NEWLINE$Den oppgitte katalogen må være  program-katalogen der $FILEININST$ ligger.$NEWLINE$$NEWLINE$Søk deg fram til program-katalogen pånytt.
    GoTo Label: Finn Programkatalog 2
  end
  Does File Exist $TARGETDIR$\$HKDB$ (get result into variable FILEEXIST)
  if Variable FILEEXIST not Equals TRUE
    MessageBox: $PROGRAM$ - Advarsel, $HKDB$ ble ikke funnet i Program-katalogen!$NEWLINE$$NEWLINE$Konverteringen avsluttes.
  else
    Copy Local Files $TARGETDIR$\$HKDB$ to $SETUPDIR$\$HKDB$
    Run Program $SETUPDIR$\HKDBKonv.exe  (WAIT, get result into variable RUNHKDBKONV)
    Delete Files $SETUPDIR$\$HKDB$ (when installing)
  end
  Set Variable NATIVE_ENGINE to FALSE
  GoTo Label: Setup Menu
   
  label: Oppgrader
  Set Variable NATIVE_ENGINE to TRUE
  label: Finn Programkatalog 1
  Set Variable TARGETDIR to 
  Display Dialog: destination, wait for dialog to return (modal)
  if Variable WIZARD Equals CANCEL
    GoTo Label: Setup Menu
  end
  Parse String $SETUPPATH$ into Variables SETUPDIR and REST (Split at last occurrence of pattern)
  Does File Exist $TARGETDIR$\$FILEININST$ (get result into variable FILEEXIST)
  if Variable FILEEXIST not Equals TRUE
    MessageBox: $PROGRAM$ - Advarsel, Dette er ikke program-katalogen!$NEWLINE$$NEWLINE$Den oppgitte katalogen må være  program-katalogen der $FILEININST$ ligger.$NEWLINE$$NEWLINE$Søk deg fram til program-katalogen pånytt.
    GoTo Label: Finn Programkatalog 1
  end
  Parse String $SETUPDIR$ into Variables PROGDIR and REST (Split at last occurrence of pattern)
  Does Folder Exist $TARGETDIR$\Arkiv (get result into variable FOLDEREXIST)
  if Variable FOLDEREXIST not Equals TRUE
    Create Folder $TARGETDIR$\Arkiv
  end
  Does File Exist $SETUPDIR$\Program\$FILEININST$ (get result into variable FILEEXIST)
  if Variable $FILEEXIST$ not Equals TRUE
    MessageBox: $PROGRAM$ - Advarsel, Finner ikke nedlastede filer!$NEWLINE$$NEWLINE$Last ned og pakk ut pånytt.
    GoTo Label: Setup Menu
  end
  Check File Version $SETUPDIR$\Program\$FILEININST$ into Variable FILEISNEWER
  Get File Version $TARGETDIR$\$FILEININST$ into Variable OLDVERSION
  Get File Version $SETUPDIR$\Program\$FILEININST$ into Variable NEWVERSION
   
  Comment: Add/Substitute files in the Program Folder
  Find All Files in path $SETUPDIR$\Program\*.*, write result into variable NEWFILES
   
  Display Dialog: progress, use as progress dialog (non-modal)
   
  for each Element FILE in | delimited Collection of $NEWFILES$ do
    Parse String $FILE$ into Variables REST and ACTIVEFILE (Split at last occurrence of pattern)
    if Variable FILEISNEWER Equals TRUE
      Delete Files $TARGETDIR$\Arkiv\$ACTIVEFILE$ (when installing)
      Move Local Files $TARGETDIR$\$ACTIVEFILE$ to $TARGETDIR$\Arkiv\
    end
    Delete Files $TARGETDIR$\$ACTIVEFILE$ (when installing)
    Copy Local Files $SETUPDIR$\Program\$ACTIVEFILE$ to $TARGETDIR$\
  next
   
  Comment: Delete old versions of Maler and Utskrifter
  Does File Exist $SETUPDIR$\Program\RemoveVersion\RemoveVersion.exe (get result into variable FILEEXIST)
  if Variable FILEEXIST Equals TRUE
    Get File Version $SETUPDIR$\Program\RemoveVersion\RemoveVersion.exe into Variable REMOVEVERSION
    Delete Files $TARGETDIR$\Maler\Maler_$REMOVEVERSION$\*.* (when installing)
    Delete Files $TARGETDIR$\Utskrifter\Utskrifter_$REMOVEVERSION$\*.* (when installing)
  end
   
  Comment: Add/Substitute files in Utskrifter
  Set Variable NEWFILES to 
  Delete Files $TARGETDIR$\Utskrifter\Utskrifter_$NEWVERSION$\*.* (when installing)
  Find All Files in path $SETUPDIR$\Program\Utskrifter\*.*, write result into variable NEWFILES
  for each Element FILE in | delimited Collection of $NEWFILES$ do
    Parse String $FILE$ into Variables REST and ACTIVEFILE (Split at last occurrence of pattern)
    Delete Files $TARGETDIR$\Utskrifter\Utskrifter_$NEWVERSION$\$ACTIVEFILE$ (when installing)
    Copy Local Files $SETUPDIR$\Program\Utskrifter\$ACTIVEFILE$ to $TARGETDIR$\Utskrifter\Utskrifter_$NEWVERSION$\
  next
   
  Comment: Add/Substitute files in Maler
  Set Variable NEWFILES to 
  Delete Files $TARGETDIR$\Maler\Maler_$NEWVERSION$\*.* (when installing)
  Find All Files in path $SETUPDIR$\Program\Maler\*.*, write result into variable NEWFILES
  for each Element FILE in | delimited Collection of $NEWFILES$ do
    Parse String $FILE$ into Variables REST and ACTIVEFILE (Split at last occurrence of pattern)
    Delete Files $TARGETDIR$\Maler\Maler_$NEWVERSION$\$ACTIVEFILE$ (when installing)
    Copy Local Files $SETUPDIR$\Program\Maler\$ACTIVEFILE$ to $TARGETDIR$\Maler\Maler_$NEWVERSION$\
  next
   
  Hide Dialog
   
  MessageBox: $PROGRAM$, Program-oppgraderingen er utført!$NEWLINE$$NEWLINE$Gammel programversjon: $OLDVERSION$$NEWLINE$$NEWLINE$Ny programversjon: $NEWVERSION$
  Set Variable NATIVE_ENGINE to FALSE
  GoTo Label: Setup Menu
   
  label: Hjemmeside
  Run Program http://www.hk-data.no 
  GoTo Label: Setup Menu
   
  label: FINISHPROJECT
  [compiler end]
  Set Variable PROGRESS to 100
end
Comment: Apply Uninstall (get result into variable SUCCESS)
Comment: Terminate Installation
[END REGION]
 
[DEFINE REGION: Finish Setup]
Comment: End of Installation
Hide Dialog
Comment: Display Dialog: finish, wait for dialog to return (modal)
if Variable SILENT Equals FALSE
  if Variable REBOOTCOMPUTER Equals TRUE
    if Variable SUCCESS Equals REBOOT
      Reboot Computer
    end
  end
  if Variable RUNAPP Equals TRUE
    if Variable REMOVE Equals FALSE
      if Variable SUCCESS Equals COMPLETE
        Comment: TO-DO: Insert command that starts your application here
      end
    end
  end
end
[END REGION]
 
